<template>
	<view class="index-product-wrapper" v-if="tempArr.length"
		:style="{ marginTop: mbConfig + 'rpx',borderRadius: bgStyle+'rpx'}">
		<view class="heard">
			<view class="heard_left">
				<view class="heard_image">
					<image :src="title_icon" mode=""></image>
				</view>
				<view class="heard_title">
					{{title}}
				</view>
			</view>
			<view class="heard_right" @click="moreClick">
				查看更多
				<image src="../../../static/images/arrow-right.png" mode=""></image>
			</view>
		</view>
		<!-- 单列 -->
		<block v-if="itemStyle == 0">
			<view class="list-box animated listA" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
				<view class="item"  v-for="(item, index) in tempArr" :key="index" :style="{background: themeColor}" @click="goDetail(item)">
					<view class="text-info"
						style="display: flex; flex-direction: column; justify-content: space-between;">
						<view class="title" style="color: #000000;font-size: 14px;font-weight: bolder;">{{ item.title }}
						</view>
						<view class="" style="color: #282828;font-size: 12px;">
							{{item.create_time}}
						</view>

					</view>
					<view class="pictrue" style="height: 200rpx;padding-top: 20rpx;margin-right: 10px;" :class="'cont'+conStyle">
						<easy-loadimage mode="widthFix" :image-src="item.image_input"></easy-loadimage>
					</view>
				</view>
			</view>
		</block>
		<!-- 两列 -->
		<block v-if="itemStyle == 1">
			<view class="list-box listS animated" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
				<view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)"
					:style="'border-radius:'+bgStyle+'rpx;'">
					<view class="pictrue picture1" :class="'cont'+conStyle">
						<easy-loadimage mode="widthFix" :image-src="item.image_input"></easy-loadimage>
					</view>
					<view class="text-info" style="background:#fff;">
						<view class="line2" style="overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 1;
						-webkit-box-orient: vertical;">{{ item.title }}</view>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	import {
		getcidList
	} from '@/api/userminp.js';
	export default {
		name: 'seekList',
		props: {
			dataConfig: {
				type: Object,
				default: () => {}
			},
			merId: {
				type: String || Number,
				default: ''
			}
		},
		data() {
			return {
				tempArr: [],
				mbConfig: this.dataConfig.mbConfig.val * 2,
				numConfig: this.dataConfig.numConfig.val ? this.dataConfig.numConfig.val : this.dataConfig.numConfig.val,
				title: this.dataConfig.swiperConfig.list[0].info[0].value,
				title_icon: this.dataConfig.swiperConfig.list[0].img,
				itemStyle: this.dataConfig.itemStyle.type,
				themeColor: this.dataConfig.themeColor.color[0].item,
				bgStyle: this.dataConfig.bgStyle.type ? '20' : '0',
				conStyle: this.dataConfig.conStyle.type,
				selectConfig:this.dataConfig.selectConfig.activeValue,
				moreUrl:this.dataConfig.swiperConfig.list[0].info[1].value
			};
		},
		mounted() {
			this.productslist();
		},
		methods: {
			productslist() {
				getcidList(this.selectConfig, {
					enterprise_id: uni.getStorageSync('QIYEID')
				}).then(res => {
					this.tempArr = res.data.list;
					this.tempArr=this.tempArr.slice(0,this.numConfig)
				});
			},
			goDetail(item) {
				this.$emit('detail', item);
			},
			moreClick(){
				uni.navigateTo({
					url:`${this.moreUrl}&title=${this.title}`
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.heard {
		width: 90vw;
		margin-left: 2vw;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-top: 10px;

		.heard_left {
			display: flex;
			align-items: center;

			.heard_image {
				height: 60rpx;
				width: 60rpx;
				border-radius: 50%;
				background-color: #000000;
				margin-right: 10rpx;
				padding: 4.5rpx;

				image {
					height: 50rpx;
					width: 50rpx;
					border-radius: 50%;
				}
			}

			.heard_title {
				font-size: 14px;
				font-weight: bolder;
			}
		}

		.heard_right {
			font-size: 12px;
			color: #282828;

			image {
				height: 20rpx;
				width: 20rpx;
				margin-left: 10rpx;
			}
		}
	}


	.index-product-wrapper {
		margin: 20rpx 15rpx 0 20rpx;

		.list-box {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			padding: 0rpx 20rpx 0;
			margin-bottom: 20rpx;
			.item {
				width: 328rpx;
				margin-bottom: 20rpx;
				overflow: hidden;
				position: relative;

				&.on {
					border-radius: 0;
				}

				.pictrue_log {
					width: 92rpx;
					height: 44rpx;
					font-size: 26rpx;
					line-height: 44rpx;
				}

				.pictrue,
				/deep/image,
				/deep/.easy-loadimage,
				/deep/uni-image {
					width: 100%;
					display: block;
					position: relative;

					.border-picture {
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						background: center/cover no-repeat;
					}
				}

				.picture1,
				/deep/.picture1 image,
				/deep/.picture1 .easy-loadimage,
				/deep/.picture1 uni-image {
					height: 346rpx;
					position: relative;

					.border-picture {
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						background: center/cover no-repeat;
					}

					.sell_out {
						display: flex;
						width: 150rpx;
						height: 150rpx;
						align-items: center;
						justify-content: center;
						border-radius: 100%;
						background: rgba(0, 0, 0, .6);
						color: #fff;
						font-size: 30rpx;
						position: absolute;
						top: 50%;
						left: 50%;
						margin: -75rpx 0 0 -75rpx;

						&::before {
							content: "";
							display: block;
							width: 140rpx;
							height: 140rpx;
							border-radius: 100%;
							border: 1px dashed #fff;
							position: absolute;
							top: 5rpx;
							left: 5rpx;
						}
					}
				}

				.cont1,
				/deep/.cont1 image,
				/deep/.cont1 .easy-loadimage,
				/deep/.cont1 uni-image,
				.cont1 .border-picture {
					border-radius: 16rpx;
				}

				.text-info {
					padding: 10rpx 20rpx 15rpx;

					.title {
						color: #222222;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
					}

					.old-price {
						margin-top: 4rpx;
						font-size: 26rpx;
						color: #999;
						text-decoration: line-through;

						text {
							margin-right: 2px;
							font-size: 20rpx;
						}
					}

					.price {
						display: flex;
						margin-top: 20rpx;
						font-size: 26rpx;
						align-items: center;

						text {
							font-size: 36rpx;
							font-weight: 550;
						}

						.ot-price {
							color: #aaa;
							font-size: 26rpx;
							text-decoration: line-through;
							margin-left: 6rpx;
							font-weight: normal;
							margin-top: 10rpx;
						}
					}
				}

				.pictrue {
					position: relative;
				}

				.border-picture {
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
					border-radius: 8rpx;
					background: center/cover no-repeat;
				}
			}

			.merchant_info {
				display: flex;
				align-items: center;
				margin-top: 20rpx;

				.merchant_type {
					color: #fff;
					line-height: 30rpx;
					padding: 0 10rpx;
					border-radius: 2rpx;
					font-size: 22rpx;
				}

				.txt {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 56rpx;
					height: 28rpx;
					margin-left: 15rpx;
					border: 1px solid $theme-color;
					border-radius: 4rpx;
					font-size: 20rpx;
					font-weight: normal;

					&.delivery {
						// margin-left: 0;
						color: #FF9000;
						border-color: #FF9000;
					}
				}
			}

			&.on {
				display: flex;
			}

			&.listA {
				.item {
					display: flex;
					width: 100%;

					.pictrue,
					/deep/image,
					/deep/.easy-loadimage,
					/deep/uni-image {
						width: 240rpx;
						height: 160rpx;
					}

					.sell_out {
						display: flex;
						width: 110rpx;
						height: 110rpx;
						align-items: center;
						justify-content: center;
						border-radius: 100%;
						background: rgba(0, 0, 0, .6);
						color: #fff;
						font-size: 24rpx;
						position: absolute;
						top: 50%;
						left: 50%;
						margin: -55rpx 0 0 -55rpx;

						&::before {
							content: "";
							display: block;
							width: 100rpx;
							height: 100rpx;
							border-radius: 100%;
							border: 1px dashed #fff;
							position: absolute;
							top: 5rpx;
							left: 5rpx;
						}
					}

					.text-info {
						width: 490rpx;
					}
				}
			}

			&.listB {
				justify-content: inherit;

				.item {
					width: 31.3%;
					margin-right: 3.05%;

					.pictrue,
					/deep/image,
					/deep/.easy-loadimage,
					/deep/uni-image {
						height: 220rpx;
					}

					.sell_out {
						display: flex;
						width: 110rpx;
						height: 110rpx;
						align-items: center;
						justify-content: center;
						border-radius: 100%;
						background: rgba(0, 0, 0, .6);
						color: #fff;
						font-size: 24rpx;
						position: absolute;
						top: 50%;
						left: 50%;
						margin: -55rpx 0 0 -55rpx;

						&::before {
							content: "";
							display: block;
							width: 100rpx;
							height: 100rpx;
							border-radius: 100%;
							border: 1px dashed #fff;
							position: absolute;
							top: 5rpx;
							left: 5rpx;
						}
					}

					&:nth-child(3n) {
						margin-right: 0;
					}

					.price {
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 20rpx;

						text {
							font-size: 28rpx;
						}
					}

					.text-info {
						padding: 10rpx 4rpx;
					}
				}
			}

			&.listC {
				.item {
					width: 100%;

					.pictrue,
					/deep/image,
					/deep/.easy-loadimage,
					/deep/uni-image {
						height: 320rpx;
					}

					.price {
						margin-top: 20rpx;
						font-size: 40rpx;
						display: flex;
						align-items: center;

						.old-price {
							font-weight: normal;
							font-size: 22rpx;
							margin-left: 10rpx;
						}
					}
				}
			}

			&.listS {
				.price {
					font-size: 40rpx;
					display: flex;
					align-items: baseline;

					.old-price {
						font-weight: normal;
						font-size: 22rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>